<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="css/eui.css">
  <style>
    body{
      font: 18px "Microsoft YaHei UI";
      margin: 0;
      background-color: #fafafa;
    }
    header,main,footer{
      padding-left: 0 !important;
      padding-right: 0 !important;
    }

    header a{
      text-decoration: none;
      color: #6c6c6c;
    }
    header a:hover{
      color: #0aa1ed;
    }
    .el-input__inner{
      padding-right: 35px;
    }
    /*销量排行榜表格间距*/
    .el-table .el-table__cell{
      padding: 0;
    }
    /*给图片添加阴影*/
    .item_div>img:hover{
      position: relative;
      bottom: 5px;
      /*元素阴影: x偏移值 y偏移值 浓度 范围 颜色*/
      box-shadow: 0 0 12px 5px #333;
    }
    /*去掉多于滚动条*/
    .el-main{
      overflow: hidden;
    }
  </style>
</head>
<body>
<div id="app">
<el-container>
  <el-header>
    <div style="width: 1200px;margin: 0 auto">
      <img src="imgs/logo.png" style="width: 300px;vertical-align: middle" alt="">
      <span style="margin-left: 50px">
        <a href="/" style="color: #0aa1ed">首页</a><el-divider direction="vertical"></el-divider>
        <a href="">热点咨询</a><el-divider direction="vertical"></el-divider>
        <a href="">社会招聘</a><el-divider direction="vertical"></el-divider>
        <a href="">校园招聘</a><el-divider direction="vertical"></el-divider>
        <a href="">帮助中心</a>
      </span>
    </div>
    <!--蓝条开始-->
    <div style="width: 100%;height:60px;background-color: #82c8ec">
      <el-menu style="width: 1200px;margin: 0 auto"

              class="el-menu-demo"
              mode="horizontal"
              @select="handleSelect"
              background-color="#82c8ec"
              text-color="#fff"
              active-text-color="#fff">
        <el-menu-item v-for="c in categoryArr" :index="c.id">{{c.name}}</el-menu-item>
        <el-menu-item index="-1" style="float: right">
          <el-input size="mini" v-model="wd" placeholder="请输入关键字搜索"></el-input>
        </el-menu-item>
        <el-button style="float: right;background-color: rgba(0,0,0,0);border:none;position: relative;top: 15px;left: 220px"
                   icon="el-icon-search"></el-button>
      </el-menu>
    </div>
    <!--蓝条结束-->
  </el-header>
  <el-main style="width: 1200px;margin: 100px auto 0 auto">
    <!--商品详情开始-->
    <el-row gutter="20">
      <el-col span="12">
        <el-card>
          <!--大图预览-->
          <!--<div class="demo-image__preview">
            <el-image :src="p.url" style="width: 100%"
            :preview-src-list="[p.url]">
            </el-image>
          </div>-->
          <img :src="p.url" width="100%" alt="">
        </el-card>
      </el-col>
      <el-col span="12">
        <p style="font-size: 25px;line-height: 45px">
          {{p.title}}
        </p>
        <el-divider></el-divider>
        <p style="font-size: 15px;color: #999">
          销量:{{p.saleCount}} 浏览量:{{p.viewCount}}
        </p>
        <p style="font-size: 25px;font-weight: bold">
        $:{{p.price}}
        <span style="font-size: 15px;color: #999">
          原价:<s>{{p.oldPrice}}</s>
        </span>
        </p>
        <el-row gutter="20" style="color: #999;text-align: center">
          <el-col span="8">
            <el-card>
              <img src="imgs/ewm.jpg" width="100%">
            </el-card>
            <span>扫码购买商品</span>
          </el-col>
          <el-col span="8">
            <el-card>
              <img src="imgs/ewm.jpg" width="100%">
            </el-card>
            <span>扫码关注公众号</span>
          </el-col>
          <el-col span="8">
            <el-card>
              <img src="imgs/ewm.jpg" width="100%">
            </el-card>
            <span>扫码下载App</span>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <!--商品详情结束-->
  </el-main>
  <el-footer>
    <div style="background-image: url('imgs/wave.png');
    height: 95px;margin-bottom: -30px"></div>
    <div style="background-color: #3f3f3f;padding: 30px;
    text-align: center;color: #b1b1b1;font-size: 14px;height: 100px">
      <p>Copyright © 北京达内金桥科技有限公司版权所有 京ICP备12003709号-3 京公网安备 11010802029572号</p>
      <p>涵盖20余门课程体系，致力于打造权威的IT职业教育学习平台</p>
      <p>达内在线WWW.TMOOC.CN 专注于IT职业技能培训</p>
    </div>
  </el-footer>
</el-container>

</div>
</body>
<script src="js/vue.min.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
  let v = new Vue({
    el: '#app',
    data: function() {
      return {
        wd:"",
        categoryArr:[],
        p:{}  //表示装着详情的商品对象
      }
    },
    methods:{
      handleSelect(index){
        if (index!=-1){
          location.href="/result.html?cid="+index;
        }
      }
    },
    created:function () {
      //发送请求获取所有的分类信息
      axios.get("/category/select").then(function (response) {
        v.categoryArr = response.data;
      })

      //获取商品id
      let id = location.search.split("=")[1];
      //通过id查询商品信息
      axios.get("/product/selectById?id="+id).then(function (response) {
        v.p=response.data;
      })
    }
  })
</script>
</html>